{include file="public/header" /}
<link rel="stylesheet" href="/static/admin/css/base.css" media="all">
<style>
    html {
        background-color: #f2f2f2 !important;
    }
    .remark{margin-left: 130px;margin-top: 8px;color: #868686;font-size: 13px;}
    .suffix_div{float: left;width: 40%}
    .suffix_span{float: left;margin-top: .7rem}
    .layui-input-block{width: 40%;margin-left: 130px!important;}
    .layui-form-label{width: 100px;!important;}
    .layui-form-item{padding-bottom: 10px}
</style>

<body>
<div class="layui-fluid layui-anim-fadein" style="margin-bottom: 2rem;">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-tab layui-tab-brief">
                <ul class="layui-tab-title">
                    {foreach name=":get_config_group()" item="group" key="key"}
                    <a href="{:url('?id='.$key)}"><li {eq name="$id" value="$key"}class="layui-this"{/eq}>{$group}配置</li></a>
                    {/foreach}
                </ul>
            </div>
            <div style="height: 20px"></div>
            <form action="{:url('config/saveGroup')}" method="post" class="layui-form" id="form">

                {volist name="list" id="config"}

                <div class="layui-form-item" style="margin-bottom: 20px;">
                    <label class="layui-form-label" >{$config.title}</label>
                    {switch name="config->getData('type')"}
                    {case value="1"}
                    <div class="layui-input-block">
                        {if $config.suffix}
                        <input type="text" class="layui-input suffix_div" name="config[{$config.name}]" value="{$config.value*100}">
                        <span class="suffix_span">&nbsp;&nbsp;{$config.suffix}</span>
                        {else}
                        <input type="text" class="layui-input" name="config[{$config.name}]" value="{$config.value}">
                        {/if}
                    </div>
                    <div class="remark" >
                        <span>* {$config.remark}</span>
                    </div>
                    {/case}
                    {case value="2"}
                    <div class="layui-input-block">
                        <textarea class="layui-textarea" type="text" rows="4" name="config[{$config.name}]">{$config.value}</textarea>
                    </div>
                    <div class="remark" >
                        <span>* {$config.remark}</span>
                    </div>
                    {/case}
                    {case value="3"}
                    <div class="layui-input-block">
                        <textarea class="layui-textarea" type="text" rows="4" name="config[{$config.name}]">{$config.value}</textarea>
                    </div>
                    <div class="remark" >
                        <span>* {$config.remark}</span>
                    </div>
                    {/case}
                    {case value="4"}
                    <div class="layui-input-block" >
                        <div class="layui-input-inline">
                            <select name="config[{$config.name}]">
                                {volist name=":parse_config_attr($config['extra'])" id="vo" }
                                <option {eq name="config.value" value="$key"}selected{/eq} value="{$key}">{$vo}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="remark" >
                        <span>* {$config.remark}</span>
                    </div>
                    {/case}
                    {case value="5"}
                    <div class="layui-input-block">
                        <div data-filed="{$config.name}" id="editor—wrapper" class="wang-editor editor—wrapper" data-value='<?php echo $config["value"];?>'>
                            <input type="hidden" class="editor—{$config.name}" name="config[{$config.name}]" value=''/>
                            <div class="toolbar-container" id="toolbar-container-{$config.name}"><!-- 工具栏 --></div>
                            <div class="editor-container" id="editor-container-{$config.name}"><!-- 编辑器 --></div>
                        </div>
                    </div>
                    <div class="remark" >
                        <span>* {$config.remark}</span>
                    </div>
                    {/case}
                    {case value="6"}
                    <div class="layui-input-block">
                        <div class="layui-tab-item layui-show">
                            <div class="openMaterialDraggable" id="Gallery_{$config.name}">
                                {if $config.value}
                                <div class="material-preview">
                                    <div class="del-wrap">
                                        <div style="position: relative">
                                            <div class="file-item relative" style="height: 100px; width: 100px;">
                                                <div class="el-image image">
                                                    <img src="{$config.value}" class="el-image__inner" style="object-fit: contain;">
                                                </div>
                                            </div>
                                            <div class="drop-down layui-anim layui-anim-downbit" style="display: none">
                                                <p class="openShowImg" data-value="{$config.value}">查看</p>
                                                <p data-val="{$config.value}" class="drop-del">删除</p>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                {/if}
                                <input type="hidden" class="drop-value" id="checkGallery_{$config.name}" name="config[{$config.name}]" value="{$config.value}"/>
                            </div>
                            <div class="upload-btn openGallery" data-t="1" data-n="{$config.name}" data-c="{$config.value}"
                                 style="width: 100px; height: 100px;">
                                <i class="layui-icon layui-icon-addition" style="font-size: 25px; --color: inherit;"></i>
                                <span>添加</span>
                            </div>
                        </div>
                    </div>

                    <div class="remark" >
                        <span>* {$config.remark}</span>
                    </div>
                    {/case}
                    {case value="7"}
                    <div class="layui-input-block">
                        <?php $format = explode('_',$config['format']);?>
                        <input type="text" class="layui-input config_laydate" data-format-1="{$format[0]}" data-format-2="{$format[1]}" name="config[{$config.name}]" value="{:get_layDate($config['value'],$config['format'])}" style="width: 40%">
                    </div>
                    <div class="remark" >
                        <span>* {$config.remark}</span>
                    </div>
                    {/case}
                    {case value="8"}
                    <div class="layui-input-block left_div">
                        {if $config.suffix}
                        {if $config.suffix == '%'}
                        <input type="text" class="layui-input suffix_div" name="config[{$config.name}]" value="{$config.value*100}" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">
                        {else}
                        <input type="text" class="layui-input suffix_div" name="config[{$config.name}]" value="{$config.value}" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">
                        {/if}
                        <span class="suffix_span">&nbsp;&nbsp;{$config.suffix}</span>
                        {else}
                        <input type="text" class="layui-input" name="config[{$config.name}]" value="{$config.value}" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">
                        {/if}
                    </div>
                    <div class="remark" >
                        <span>* {$config.remark}</span>
                    </div>
                    {/case}
                    {case value="9"}
                    <?php $val = explode(',',$config['value']);?>
                    <div class="layui-input-block left_div">
                        {if $config.suffix == '%'}
                        <input type="text" class="layui-input suffix_div" name="config[{$config.name}]" value="{$val[0]*100}" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" >
                        <span class="suffix_span">&nbsp;&nbsp; - &nbsp;&nbsp; </span>
                        <input type="text" class="layui-input suffix_div" name="config[{$config.name}_2]" value="{$val[1]*100}" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" >
                        <span class="suffix_span">&nbsp;&nbsp;{$config.suffix}</span>
                        {else}
                        <input type="text" class="layui-input suffix_div" name="config[{$config.name}]" value="{$val[0]}" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" >
                        <span class="suffix_span">&nbsp;&nbsp; - &nbsp;&nbsp; </span>
                        <input type="text" class="layui-input suffix_div" name="config[{$config.name}_2]" value="{$val[1]}" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" >
                        <span class="suffix_span">&nbsp;&nbsp;{$config.suffix}</span>
                        {/if}
                    </div>
                    <div class="remark" >
                        <span>* {$config.remark}</span>
                    </div>
                    {/case}
                    {case value="10"}
                    <?php $val = explode(',',$config['value']);?>
                    <div class="layui-input-block" style="width: 700px;">
                        <input type="checkbox" name="config[{$config.name}][]" value="1" title="周一" {if in_array(1,$val)}checked{/if}/>
                        <input type="checkbox" name="config[{$config.name}][]" value="2" title="周二" {if in_array(2,$val)}checked{/if}/>
                        <input type="checkbox" name="config[{$config.name}][]" value="3" title="周三" {if in_array(3,$val)}checked{/if}/>
                        <input type="checkbox" name="config[{$config.name}][]" value="4" title="周四" {if in_array(4,$val)}checked{/if}/>
                        <input type="checkbox" name="config[{$config.name}][]" value="5" title="周五" {if in_array(5,$val)}checked{/if}/>
                        <input type="checkbox" name="config[{$config.name}][]" value="6" title="周六" {if in_array(6,$val)}checked{/if}/>
                        <input type="checkbox" name="config[{$config.name}][]" value="0" title="周日" {if in_array('0',$val)}checked{/if}/>
                    </div>
                    <div class="remark" >
                        <span>* {$config.remark}</span>
                    </div>
                    {/case}
                    {/switch}
                </div>
                {/volist}
            </form>
        </div>

    </div>
</div>
<div class="layui-form-item layui-layout-admin">
    <div class="layui-input-block">
        <div class="layui-footer" style="left: 0;">
            <button class="layui-btn" lay-filter="save" lay-submit formObj="#form">保存</button>
        </div>
    </div>
</div>

<script id="GalleryTemplate1" type="text/html">
    {{# for(var i=0;i < d.data.length ;i++){ }}
    <div class="material-preview">
        <div class="del-wrap">
            <div>
                <div class="file-item relative" style="height: 100px; width: 100px;">
                    <div class="el-image image">
                        <img src="{{d.data[i]}}" class="el-image__inner" style="object-fit: contain;">
                    </div>
                </div>
                <div class="drop-down layui-anim layui-anim-downbit" style="display: none">
                    <p class="openShowImg" data-value="{{d.data[i]}}">查看</p>
                    <p data-val="{{d.data[i]}}" class="drop-del">删除</p>
                </div>
            </div>
        </div>
    </div>
    {{# } }}
    <input type="hidden" class="drop-value" id="checkGallery_{{d.name}}" name="config[{{d.name}}]" value="{{(d.data).join(',')}}"/>
</script>
</body>
{include file="public/footer" /}
</html>